from django.urls import include, path
from django.views.generic.base import RedirectView

from eventyay.orga.views import (
    admin,
    auth,
    cards,
    cfp,
    dashboard,
    event,
    mails,
    organizer,
    person,
    plugins,
    review,
    schedule,
    speaker,
    submission,
    typeahead,
)

app_name = 'orga'
urlpatterns = [
    path("", RedirectView.as_view(url="event", permanent=False), name="base"),
    path("reset/", auth.ResetView.as_view(), name="auth.reset"),
    path("reset/<token>", auth.RecoverView.as_view(), name="auth.recover"),
    path('admin/', admin.AdminDashboard.as_view(), name='admin.dashboard'),
    path('admin/update/', admin.UpdateCheckView.as_view(), name='admin.update'),
    path(
        'admin/users/<slug:code>/',
        admin.AdminUserDetail.as_view(),
        name='admin.user.view',
    ),
    path(
        'admin/users/<slug:code>/delete/',
        admin.AdminUserDelete.as_view(),
        name='admin.user.delete',
    ),
    path('admin/users/', admin.AdminUserList.as_view(), name='admin.user.list'),
    path('me', person.UserSettings.as_view(), name='user.view'),  # Change this to common/account/general.
    path('me/subuser', person.SubuserView.as_view(), name='user.subuser'),
    path(
        'invitation/<code>',
        event.InvitationView.as_view(),
        name='invitation.view',
    ),
    path('nav/typeahead/', typeahead.nav_typeahead, name='nav.typeahead'),
        path(
        "organizer/",
        dashboard.DashboardOrganizerListView.as_view(),
        name="organizer.list",
    ),
    path("organizer/new", organizer.OrganizerDetail.as_view(), name="organizer.create"),
    path(
        "organizer/<slug:organizer>/",
        include(
            [
                path(
                    "",
                    dashboard.DashboardOrganizerEventListView.as_view(),
                    name="organizer.dashboard",
                ),
                path(
                    "settings/",
                    organizer.OrganizerDetail.as_view(),
                    name="organizer.settings",
                ),
                path(
                    "settings/delete/",
                    organizer.OrganizerDelete.as_view(),
                    name="organizer.delete",
                ),
                path("api/users", organizer.speaker_search, name="organizer.user_list"),
                *organizer.TeamView.get_urls(
                    url_base="teams",
                    url_name="organizer.teams",
                    namespace="orga",
                ),
                path(
                    "teams/<int:team_pk>/members/<int:user_pk>/delete/",
                    organizer.TeamMemberDelete.as_view(),
                    name="organizer.teams.members.delete",
                ),
                path(
                    "teams/<int:team_pk>/members/<int:user_pk>/reset/",
                    organizer.TeamResetPassword.as_view(),
                    name="organizer.teams.members.reset",
                ),
                path(
                    "teams/<int:pk>/invites/<int:invite_pk>/uninvite/",
                    organizer.TeamUninvite.as_view(),
                    name="organizer.teams.invites.uninvite",
                ),
                path(
                    "teams/<int:pk>/invites/<int:invite_pk>/resend/",
                    organizer.TeamResend.as_view(),
                    name="organizer.teams.invites.resend",
                ),
                path(
                    "speakers/",
                    organizer.OrganizerSpeakerList.as_view(),
                    name="organizer.speakers",
                ),
            ]
        ),
    ),
    path("event/new/", event.EventWizard.as_view(), name="event.create"),
    path("event/", dashboard.DashboardEventListView.as_view(), name="event.list"),
    path(
        'event/<slug:event>/',
        include(
            [
                path("login/", auth.LoginView.as_view(), name="event.login"),
                path("delete", event.EventDelete.as_view(), name="event.delete"),
                path("reset/", auth.ResetView.as_view(), name="event.auth.reset"),
                path(
                    "reset/<token>",
                    auth.RecoverView.as_view(),
                    name="event.auth.recover",
                ),
                path('live', event.EventLive.as_view(), name='event.live'),
                path('', dashboard.EventDashboardView.as_view(), name='event.dashboard'),
                path('history/', event.EventHistory.as_view(), name='event.history'),
                path(
                    'settings/',
                    event.EventDetail.as_view(),
                    name='settings.event.view',
                ),
                path(
                    'settings/review/',
                    event.EventReviewSettings.as_view(),
                    name='settings.review',
                ),
                path(
                    'settings/review/phase/<int:pk>/',
                    include(
                        [
                            path(
                                'activate',
                                event.PhaseActivate.as_view(),
                                name='settings.review.phase.activate',
                            ),
                        ]
                    ),
                ),
                path(
                    'settings/mail',
                    event.EventMailSettings.as_view(),
                    name='settings.mail.view',
                ),
                path(
                    'settings/widget',
                    event.WidgetSettings.as_view(),
                    name='settings.widget',
                ),
                path(
                    'settings/plugins',
                    plugins.EventPluginsView.as_view(),
                    name='settings.plugins.select',
                ),
                path(
                    'cfp/',
                    RedirectView.as_view(pattern_name='orga:cfp.text.view'),
                    name='cfp',
                ),
                path('cfp/text/', cfp.CfPTextDetail.as_view(), name='cfp.text.view'),
                path('cfp/flow/', cfp.CfPFlowEditor.as_view(), name='cfp.flow'),
                *cfp.QuestionView.get_urls(
                    url_base='cfp/questions',
                    url_name='cfp.questions',
                    namespace='orga',
                ),
                path(
                    'cfp/questions/remind/',
                    cfp.CfPQuestionRemind.as_view(),
                    name='cfp.questions.remind',
                ),
                path(
                    'cfp/questions/<int:pk>/toggle/',
                    cfp.CfPQuestionToggle.as_view(),
                    name='cfp.question.toggle',
                ),
                *cfp.TrackView.get_urls(
                    url_base='cfp/tracks',
                    url_name='cfp.tracks',
                    namespace='orga',
                ),
                *cfp.SubmissionTypeView.get_urls(
                    url_base='cfp/types',
                    url_name='cfp.types',
                    namespace='orga',
                ),
                path(
                    'cfp/types/<int:pk>/default/',
                    cfp.SubmissionTypeDefault.as_view(),
                    name='cfp.type.default',
                ),
                *cfp.AccessCodeView.get_urls(
                    url_base='cfp/access-codes',
                    url_name='cfp.access_code',
                    namespace='orga',
                ),
                path(
                    'cfp/access-codes/<slug:code>/send',
                    cfp.AccessCodeSend.as_view(),
                    name='cfp.access_code.send',
                ),
                path(
                    'submissions/',
                    submission.SubmissionList.as_view(),
                    name='submissions.list',
                ),
                path(
                    'submissions/new',
                    submission.SubmissionContent.as_view(),
                    name='submissions.create',
                ),
                path(
                    'submissions/cards/',
                    cards.SubmissionCards.as_view(),
                    name='submissions.cards',
                ),
                path(
                    'submissions/feed/',
                    submission.SubmissionFeed(),
                    name='submissions.feed',
                ),
                path(
                    'submissions/apply-pending/',
                    submission.ApplyPendingBulk.as_view(),
                    name='submissions.apply_pending.bulk',
                ),
                path(
                    'submissions/statistics/',
                    submission.SubmissionStats.as_view(),
                    name='submissions.statistics',
                ),
                path(
                    'submissions/feedback/',
                    submission.AllFeedbacksList.as_view(),
                    name='submissions.feedback',
                ),
                *submission.TagView.get_urls(
                    url_base='submissions/tags',
                    url_name='submissions.tags',
                    namespace='orga',
                ),
                path(
                    'submissions/<code>/',
                    include(
                        [
                            path(
                                '',
                                submission.SubmissionContent.as_view(),
                                name='submissions.content.view',
                            ),
                            path(
                                'submit',
                                submission.SubmissionStateChange.as_view(),
                                name='submissions.submit',
                            ),
                            path(
                                'accept',
                                submission.SubmissionStateChange.as_view(),
                                name='submissions.accept',
                            ),
                            path(
                                'reject',
                                submission.SubmissionStateChange.as_view(),
                                name='submissions.reject',
                            ),
                            path(
                                'confirm',
                                submission.SubmissionStateChange.as_view(),
                                name='submissions.confirm',
                            ),
                            path(
                                'withdraw',
                                submission.SubmissionStateChange.as_view(),
                                name='submissions.withdraw',
                            ),
                            path(
                                'delete',
                                submission.SubmissionStateChange.as_view(),
                                name='submissions.delete',
                            ),
                            path(
                                'cancel',
                                submission.SubmissionStateChange.as_view(),
                                name='submissions.cancel',
                            ),
                            path(
                                'speakers/',
                                submission.SubmissionSpeakers.as_view(),
                                name='submissions.speakers.view',
                            ),
                            path(
                                'speakers/delete',
                                submission.SubmissionSpeakersDelete.as_view(),
                                name='submissions.speakers.delete',
                            ),
                            path(
                                'reviews/',
                                review.ReviewSubmission.as_view(),
                                name='submissions.reviews',
                            ),
                            path(
                                'reviews/delete',
                                review.ReviewSubmissionDelete.as_view(),
                                name='submissions.reviews.submission.delete',
                            ),
                            path(
                                'feedback/',
                                submission.FeedbackList.as_view(),
                                name='submissions.feedback.list',
                            ),
                            path(
                                'toggle_featured',
                                submission.ToggleFeatured.as_view(),
                                name='submissions.toggle_featured',
                            ),
                            path(
                                'apply_pending',
                                submission.ApplyPending.as_view(),
                                name='submissions.apply_pending',
                            ),
                            path(
                                'anonymise/',
                                submission.Anonymise.as_view(),
                                name='submissions.anonymise',
                            ),
                            path(
                                'comments/',
                                submission.CommentList.as_view(),
                                name='submissions.comments.list',
                            ),
                            path(
                                'comments/<int:pk>/delete',
                                submission.CommentDelete.as_view(),
                                name='submissions.comments.delete',
                            ),
                            path(
                                'history/',
                                submission.SubmissionHistory.as_view(),
                                name='submissions.history',
                            ),
                        ]
                    ),
                ),
                path('speakers/', speaker.SpeakerList.as_view(), name='speakers.list'),
                path(
                    'speakers/export/',
                    speaker.SpeakerExport.as_view(),
                    name='speakers.export',
                ),
                path(
                    'speakers/<code>/',
                    include(
                        [
                            path(
                                '',
                                speaker.SpeakerDetail.as_view(),
                                name='speakers.view',
                            ),
                            path(
                                'reset',
                                speaker.SpeakerPasswordReset.as_view(),
                                name='speakers.reset',
                            ),
                            path(
                                'toggle-arrived',
                                speaker.SpeakerToggleArrived.as_view(),
                                name='speakers.arrived',
                            ),
                        ]
                    ),
                ),
                *speaker.SpeakerInformationView.get_urls(
                    url_base='info',
                    url_name='speakers.information',
                    namespace='orga',
                ),
                path(
                    'reviews/',
                    review.ReviewDashboard.as_view(),
                    name='reviews.dashboard',
                ),
                path(
                    'reviews/bulk/',
                    review.BulkReview.as_view(),
                    name='reviews.bulk',
                ),
                path(
                    'reviews/regenerate/',
                    review.RegenerateDecisionMails.as_view(),
                    name='reviews.regenerate',
                ),
                path(
                    'reviews/assign/import',
                    review.ReviewAssignmentImport.as_view(),
                    name='reviews.assign.import',
                ),
                path(
                    'reviews/assign/',
                    review.ReviewAssignment.as_view(),
                    name='reviews.assign',
                ),
                path(
                    'reviews/export/',
                    review.ReviewExport.as_view(),
                    name='reviews.export',
                ),
                path('schedule/', schedule.ScheduleView.as_view(), name='schedule.main'),
                path(
                    'schedule/export/',
                    schedule.ScheduleExportView.as_view(),
                    name='schedule.export',
                ),
                path(
                    'schedule/export/trigger',
                    schedule.ScheduleExportTriggerView.as_view(),
                    name='schedule.export.trigger',
                ),
                path(
                    'schedule/export/download',
                    schedule.ScheduleExportDownloadView.as_view(),
                    name='schedule.export.download',
                ),
                path(
                    'schedule/release',
                    schedule.ScheduleReleaseView.as_view(),
                    name='schedule.release',
                ),
                path(
                    'schedule/quick/<code>/',
                    schedule.QuickScheduleView.as_view(),
                    name='schedule.quick',
                ),
                path(
                    'schedule/reset',
                    schedule.ScheduleResetView.as_view(),
                    name='schedule.reset',
                ),
                path(
                    'schedule/toggle',
                    schedule.ScheduleToggleView.as_view(),
                    name='schedule.toggle',
                ),
                path(
                    'schedule/resend_mails',
                    schedule.ScheduleResendMailsView.as_view(),
                    name='schedule.resend_mails',
                ),
                *schedule.RoomView.get_urls(
                    url_base='schedule/rooms',
                    url_name='schedule.rooms',
                    namespace='orga',
                ),
                path(
                    'schedule/api/talks/<int:pk>/',
                    schedule.TalkUpdate.as_view(),
                    name='schedule.api.update',
                ),
                path(
                    'schedule/api/talks/',
                    schedule.TalkList.as_view(),
                    name='schedule.api.talks',
                ),
                path(
                    'schedule/api/availabilities/',
                    schedule.ScheduleAvailabilities.as_view(),
                    name='schedule.api.availabilities',
                ),
                path(
                    'schedule/api/warnings/',
                    schedule.ScheduleWarnings.as_view(),
                    name='schedule.api.warnings',
                ),
                path(
                    'mails/<int:pk>/',
                    include(
                        [
                            path(
                                '',
                                mails.MailDetail.as_view(),
                                name='mails.outbox.mail.view',
                            ),
                            path(
                                'copy',
                                mails.MailCopy.as_view(),
                                name='mails.outbox.mail.copy',
                            ),
                            path(
                                'delete',
                                mails.MailDelete.as_view(),
                                name='mails.outbox.mail.delete',
                            ),
                            path(
                                'send',
                                mails.OutboxSend.as_view(),
                                name='mails.outbox.mail.send',
                            ),
                            path(
                                'preview',
                                mails.MailPreview.as_view(),
                                name='mails.outbox.mail.preview',
                            ),
                        ]
                    ),
                ),
                *mails.MailTemplateView.get_urls(
                    url_base='mails/templates',
                    url_name='mails.templates',
                    namespace='orga',
                ),
                path(
                    'mails/compose/reminders',
                    mails.ComposeDraftReminders.as_view(),
                    name='mails.compose.draft_reminders',
                ),
                path(
                    'mails/compose',
                    mails.ComposeMailChoice.as_view(),
                    name='mails.compose.choose',
                ),
                path(
                    'mails/compose/teams/',
                    mails.ComposeTeamsMail.as_view(),
                    name='mails.compose.teams',
                ),
                path(
                    'mails/compose/sessions/',
                    mails.ComposeSessionMail.as_view(),
                    name='mails.compose.sessions',
                ),
                path('mails/sent', mails.SentMail.as_view(), name='mails.sent'),
                path(
                    'mails/outbox/',
                    mails.OutboxList.as_view(),
                    name='mails.outbox.list',
                ),
                path(
                    'mails/outbox/send',
                    mails.OutboxSend.as_view(),
                    name='mails.outbox.send',
                ),
                path(
                    'mails/outbox/purge',
                    mails.OutboxPurge.as_view(),
                    name='mails.outbox.purge',
                ),
            ]
        ),
    ),
]
